package gl.web.apk.controller;


import gl.web.apk.common.model.Blog;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * BlogValidator.
 */
public class ApkValidator extends Validator {
	final String DONOT_EMPTY = "不能为空!";
	
	protected void validate(Controller controller) {
		validateRequiredString("apk.apkname", "errapkname", DONOT_EMPTY);
		
		validateRequiredString("apk.packname", "errpackname", DONOT_EMPTY);
		validateRequiredString("apk.versionname", "errversionname", DONOT_EMPTY);
		validateRequiredString("apk.versioncode", "errversioncode", DONOT_EMPTY);
		validateRequiredString("apk.describe", "errdescribe", DONOT_EMPTY);
	}
	
	protected void handleError(Controller controller) {
		controller.keepModel(Blog.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/apk/save"))
			controller.render("add.html");
		else if (actionKey.equals("/blog/update"))
			controller.render("edit.html");
	}
}
